<template>
  <div id="app">
    <fromin @fy_text="translate_text"> </fromin>
    <fromout :txt=tt> </fromout>
  </div>
</template>

<script>
import fromin from '../components/fromin.vue';
import fromout from '../components/fromout';

export default {
  name: 'App',
  data:function(){
    return{
      tt:""
    }

  },
  components: {
    fromin,
    fromout
  },
  methods:{
    translate_text:function(text,language){
      //alert(text);https://tech.yandex.com
      //trnsl.1.1.20191110T120549Z.d0c1b74e2469ea3a.9d28df0ddd571d65f9584366cd1f04591f082f7f
      //npm install vue-resource --save
	  
	  var appid = '20180715000185607';
	  var salt = (new Date).getTime();
	  var key = 'xnhBUtz2C6QfM0GKnJI0';
	  uni.request({
	  	method:'GET',
		url:'http://api.fanyi.baidu.com/api/trans/vip/translate?appid=20180715000185607&to='+language+'&q='+text + '&from=zh'+ '&salt=' + salt + '&sign=' + MD5('20180715000185607' + text + salt + key),
		success(response) {
			this.tt=response.body.text[0] 
		}
	  })
	  
    

    },

  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
